const fs = require("fs");
const path = require("path");

function route(handle, pathname, response, param) {
  if (typeof handle[pathname] === "function") {
    handle[pathname](response, param);
  } else {
    response.writeHeader(200, { "Content-Type": "text/html" });
    fs.createReadStream(path.resolve(__dirname, "html/404.html")).pipe(response);
  }
}

module.exports = route;